//
//  OrderCell.m
//  AnnCar_user
//
//  Created by LiBenCan on 17/10/23.
//  Copyright © 2017年 LiBenCan. All rights reserved.
//

#import "OrderCell.h"

#import "UILabel+HWDUILabel.h"
@implementation OrderCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    //时间Lab
    _timeLab = [UILabel new];
    [self.contentView addSubview:self.timeLab];
    _timeLab.font = [UIFont systemFontOfSize:15*screenW_6];
    _timeLab.textColor = [UIColor colorWithHexString:@"#333333"];
    [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(15*screenW_6));
        make.right.equalTo(@(-80*screenW_6));
        make.height.equalTo(@(37*screenW_6));
        make.top.equalTo(self.contentView).offset(0);
    }];
    
    //接单状态
    _statusLab = [UILabel new];
    [self.contentView addSubview:self.statusLab];
    _statusLab.font = [UIFont systemFontOfSize:15*screenW_6];
    _statusLab.textAlignment = NSTextAlignmentRight;
    _statusLab.textColor = [UIColor colorWithHexString:@"#333333"];
    [_statusLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-15*screenW_6));
        make.left.equalTo(self.timeLab.mas_right).offset(5);
        make.height.equalTo(@(37*screenW_6));
        make.top.equalTo(self.contentView).offset(0);
    }];
    
    //画线
    _lineLab = [UILabel new];
    [self.contentView addSubview:_lineLab];
    _lineLab.backgroundColor = LineColor;
    [_lineLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(@1);
        make.left.equalTo(@(15*screenW_6));
        make.right.equalTo(@0);
        make.top.equalTo(self.statusLab.mas_bottom).offset(0);
    }];
    
    //图片
    _imageV = [UIImageView new];
    [self.contentView addSubview:_imageV];
    [_imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(20*screenW_6));
        make.top.equalTo(self.lineLab.mas_bottom).offset(20*screenW_6);
        make.height.width.equalTo(@(40*screenW_6));
    }];
    
    //洗车类型
    _kindLab = [UILabel new];
    [self.contentView addSubview:_kindLab];
    _kindLab.font = [UIFont systemFontOfSize:17*screenW_6];
    _kindLab.textColor = [UIColor colorWithHexString:@"#333333"];
    [_kindLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageV.mas_right).offset(15*screenW_6);
        make.top.equalTo(self.lineLab.mas_bottom).offset(20*screenW_6);
        make.height.equalTo(@(20*screenW_6));
        make.width.equalTo(@(150*screenW_6));
    }];
    
    //价钱
    _moneyLab = [UILabel new];
    [self.contentView addSubview:self.moneyLab];
    _moneyLab.font = [UIFont systemFontOfSize:20*screenW_6];
    _moneyLab.textColor  = [UIColor colorWithHexString:@"#e9331b"];
    _moneyLab.textAlignment = NSTextAlignmentRight;
    [_moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.kindLab.mas_right).offset(5);
        make.right.equalTo(@(-15*screenW_6));
        make.height.equalTo(@(22*screenW_6));
        make.top.equalTo(self.lineLab.mas_bottom).offset(18*screenW_6);
    }];
    
    //地址
    _addressLab = [UILabel new];
    [self.contentView addSubview:self.addressLab];
    _addressLab.numberOfLines = 0;
    _addressLab.font = [UIFont systemFontOfSize:14*screenW_6];
    _addressLab.textColor = [UIColor colorWithHexString:@"#999999"];
    [_addressLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-(60*screenW_6)));
        make.left.equalTo(self.imageV.mas_right).offset(15*screenW_6);
        make.top.equalTo(self.kindLab.mas_bottom).offset(5);
    }];
}
-(void)setDataDic:(NSDictionary *)dataDic
{
    _timeLab.text = @"下单时间:2017-04-27 14:20";//时间
    _statusLab.text = @"待接单";//接单状态
    _imageV.image = [UIImage imageNamed:@"orderWai"];//图片
    _kindLab.text = @"全车清洗";//接单种类
    _moneyLab.text = @"¥ 29";//价格
    [_moneyLab setTextFont:@"¥" font:[UIFont systemFontOfSize:14*screenW_6]];
    _addressLab.text = @"武汉市洪山区关谷大道未来之光";//地址
    
    //重新适配
    _addressLab.frame = CGRectMake(0, 0, SCREENW-130*screenW_6, 20);
    [_addressLab sizeToFit];
    if (_addressLab.frame.size.height<=20*screenW_6) {//地址高度小于20 以图片适配为准
        [_imageV mas_makeConstraints:^(MASConstraintMaker *make) {
           make.bottom.equalTo(self.contentView).offset(-(20*screenW_6));
        }];
    }else//地址高度大于20 以地址适配为准
    {
        [_addressLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@(-(60*screenW_6)));
            make.left.equalTo(self.imageV.mas_right).offset(15*screenW_6);
            make.top.equalTo(self.kindLab.mas_bottom).offset(5);
            make.height.equalTo(@(_addressLab.frame.size.height));
            make.bottom.equalTo(self.contentView).offset(-(20*screenW_6));
        }];
    }

    
}
@end
